package br.edu.unibratec.viagemfacil;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CategoriaAdapter extends ArrayAdapter<Categoria> {

	public CategoriaAdapter(Context context, List<Categoria> objects) {
		super(context, 0, 0, objects);
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;

		Categoria categoria = getItem(position);

		if (convertView == null) {
			convertView = LayoutInflater.from(getContext()).inflate(
					R.layout.linha_categoria, null);

			holder = new ViewHolder();
			holder.txtTexto = (TextView) convertView
					.findViewById(R.id.textViewCategoria);
			holder.imgFoto = (ImageView) convertView
					.findViewById(R.id.imageViewCategoria);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.txtTexto.setText(categoria.descricao);
		//BitmapManager.getInstance().loadBitmap(categoria.imagem, holder.imgFoto);

		return convertView;
	}

	static class ViewHolder {
		TextView txtTexto;
		ImageView imgFoto;
	}
}